package com.jindy.module.warningOrderView.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.module.homepage.vo.SimpleKanbanInConditionVO;
import com.jindy.module.warningOrderView.domain.WarningOrderViewVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.warningOrderView.domain.WarningOrderView;
import com.jindy.module.warningOrderView.service.IWarningOrderViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author jindy
 * @date 2023-06-13
 */
@RestController
@RequestMapping("/module/warningOrderView")
public class WarningOrderViewController extends BaseController
{
    @Autowired
    private IWarningOrderViewService warningOrderViewService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody SimpleKanbanInConditionVO simpleKanbanInConditionVO)
    {
        // startPage();
        List<WarningOrderViewVO> list = warningOrderViewService.selectWarningOrderViewList(simpleKanbanInConditionVO);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SimpleKanbanInConditionVO simpleKanbanInConditionVO)
    {
        List<WarningOrderViewVO> list = warningOrderViewService.selectWarningOrderViewList(simpleKanbanInConditionVO);
        ExcelUtil<WarningOrderViewVO> util = new ExcelUtil<WarningOrderViewVO>(WarningOrderViewVO.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:query')")
    @GetMapping(value = "/{salesmanName}")
    public AjaxResult getInfo(@PathVariable("salesmanName") String salesmanName)
    {
        return AjaxResult.success(warningOrderViewService.selectWarningOrderViewBySalesmanName(salesmanName));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarningOrderView warningOrderView)
    {
        return toAjax(warningOrderViewService.insertWarningOrderView(warningOrderView));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarningOrderView warningOrderView)
    {
        return toAjax(warningOrderViewService.updateWarningOrderView(warningOrderView));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:warningOrderView:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{salesmanNames}")
    public AjaxResult remove(@PathVariable String[] salesmanNames)
    {
        return toAjax(warningOrderViewService.deleteWarningOrderViewBySalesmanNames(salesmanNames));
    }
}
